package cn.glow.readingcloud.gateway.config;


import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

/**
 * @Author Glow
 * @Date 2023-04-29 14:38:36
 * @Description
 * @Version 1.0
 */

@Configuration
public class RedisRateLimiterConfig {
    /**
     * 按客户端IP限流
     * @return
     */
    @Bean
    public KeyResolver ipKeyResolver() {
        return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
    }
}